﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework5
{
    public class Goods
    {
        public string Name
        {
            get;set;
        }
        public int Num
        {
            get;set;
        }
        public double Price
        {
            get;set;
        }

        public Goods()
        {
        }

        public Goods(string name, int num, double price)
        {
            Name = name;
            Num = num;
            Price = price;
        }


        public override string ToString()
        {
            return $"商品名称：{Name}，数量：{Num}，单价：{Price}";
        }

        public override bool Equals(object obj)
        {
            var goods = obj as Goods;
            return goods != null &&
                   Name == goods.Name &&
                   Num == goods.Num &&
                   Price == goods.Price;
        }

        public override int GetHashCode()
        {
            var hashCode = -520337541;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
            hashCode = hashCode * -1521134295 + Num.GetHashCode();
            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            return hashCode;
        }
    }
}
